// pages/mockexam/theory/post/index.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    options: '',
    headList: [],
    hours:'0'+0,
    minute:'0'+0,
    second:'0'+0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    options = JSON.parse(options.dataset);
    this.setData({
      options: options,
      minute: options.upendtime,
    })
    this.setInterval();
    wx.setNavigationBarTitle({
      title: options.titlename,
    })
    var _this = this;
    app.paiRequest("/app/examinate/headList", {
      examId: options.id
    }).then(function (res) {
      console.log("kkkkkkkkkkkkk");
      console.log(res);
      var headList = res.data;
      _this.setData({
        headList: headList
      })
    })
  },
  setInterval:function(){
       var that=this;
       var second=60;
       var minute=that.data.minute;
     setInterval(function(){
         second--
         if (second<=0){
           
           second=60;
           minute--;
           if(minute<=0){
             minute = '0' + 0;
             that.setData({
               minute: minute
             })             
           }
           if (minute < 10) {
             minute = '0' + minute;
           }
           
           that.setData({
             minute: minute
           })
         }else{
           if (second < 10) {
             second = '0' + second;
           }
           that.setData({
             second: second
           })
         }
       },1000);
  },
  selectNav: function (e) {
    console.log(e);
    var data = e.currentTarget.dataset;
    var options = this.data.options;
    wx.navigateTo({
      url: 'detail/index?id=' + data.id + '&title=' + data.title + '&theoryId=' + options.id + '&signup=' + options.signup + '&scene=' + this.data.options.scene,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})